package ui2;

import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class OpeningUIController implements ActionListener {
	private FirstFrame openingView;
	
	public OpeningUIController()
	{
		super();
		
		openingView = null;
	}
	
	public void start()
	{
		final OpeningUIController controller = this;
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					openingView = new FirstFrame();
					openingView.getOkButton().addActionListener(controller);
					openingView.getFrame().setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	@Override
	public void actionPerformed(ActionEvent sender) {
		// TODO Auto-generated method stub
		if(openingView.getConfigFileTextBox().getText().length()>0){
				UIMainController mainController = new UIMainController(openingView.getConfigFileTextBox().getText(), 
						openingView.getDiscoveryModeCheckBox().isSelected());
				mainController.start();
				openingView.getFrame().setVisible(false);
		}
	}
	
	public static void main(String[] args)
	{
		OpeningUIController openingController = new OpeningUIController();
		openingController.start();
	}

}
